<template>
	<view>
		<u-navbar :is-back="false"></u-navbar>
		
		<u-notice-bar duration="1000" font-size="30" type="primary" mode="horizontal" :list="list"></u-notice-bar>
		
		<view class="study">
			<view v-for="(item,index) in studyList" :key="item.book_id" class="studyList">
				<view class="studyList-image" @click="toStudyList(item.book_id,item.title,item.intro)">
					<u-image width="100%" height="160rpx" :src="item.img" :fade="true" duration="500">
						<u-loading slot="loading"></u-loading>
					</u-image>
					<!-- <image :src="item.img" mode=""></image> -->
				</view>
				<view class="studyList-text">
					<view class="one u-line-1">
						<text @click="toStudyList(item.book_id,item.title,item.intro)">{{item.title}}</text>
					</view>
					<view class="two u-line-3">
						<text @click="toStudyList(item.book_id,item.title,item.intro)">{{item.intro}}</text>
					</view>					
				</view>
				<view class="studyList-button">
					<u-button type="primary" size="mini" @click="toStudyList(item.book_id,item.title,item.intro)">阅读</u-button>
				</view>
			</view>
		</view>
		
		<Tabbar></Tabbar>
	</view>
</template>

<script>
	import {getStudyList} from '../../utils/study.js'
	
	export default {
		data() {
			return {
				studyList:[],
				list:['还躺在被窝吃零食刷视频睡懒觉吗','快来加入我们一起内卷吧!!!']
			};
		},
		methods:{
			async getStudyListData(){
				let result = await getStudyList()
				if(result.code === 200){
					this.studyList = result.data
				}
			},
			//点击去学习手册列表
			toStudyList(id,title,intro){
				uni.navigateTo({
					url:`/subpkg/studyList/studyList?book_id=${id}&title=${title}&intro=${intro}`
				})
			}
		},
		onLoad() {
			this.getStudyListData()
		}
	}
</script>

<style lang="scss" scoped>
.study{
	width: 95%;
	margin: 0 auto;
	padding-top: 80rpx;
	
	.studyList{
		width: 100%;
		display: flex;
		
		padding-bottom: 65rpx;
		
		.studyList-image{
			width: 30%;
			
			image{
				width: 100%;
				height: 170rpx;
				border-radius: 10px;
			}
		}
		
		.studyList-text{
			width: 50%;
			padding-left: 15rpx;
			
			
			
			.one{
				font-size: 35rpx;
				font-weight: bold;
				// padding-bottom: 60rpx;
				margin-bottom: 10rpx;
			}
			
			.two{
				font-size: 26rpx;
				color: #82848a;
			}
		}
		
		.studyList-button{
			padding-left: 10rpx;
			width: 20%;
			display: flex;
			align-items: center;
		}
	}
}
</style>
